<!--大小额借记业务复合-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :defaultEventKey="defaultEventKey"
    >
    </ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="coreId"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :defaultEventKey="defaultEventKey"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                }
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-dialog ref="queryDetailDialog" :dictMap="dictMap" @editComplete="editComplete"></query-detail-dialog>
    <detail5007 ref="detail5007" :dictMap="dictMap" @editComplete="editComplete"></detail5007>
    <detail5008 ref="detail5008" :dictMap="dictMap" @editComplete="editComplete"></detail5008>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { apiUrlConfigCheck2 } from "@/api/cnaps/baseBiz/send/check/creditCheck";
import { amountThousandsFormatter } from "@/utils/table_col_formatter";
import QueryDetailDialog from "./components/Details";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
import Detail5007 from "@/views/cnaps/baseBiz/send/check/creditCheck/components/detail5007";
import Detail5008 from "@/views/cnaps/baseBiz/send/check/creditCheck/components/detail5008";
export default {
  name: "CreditCheck",
  mixins: [listPageMixin],
  components: {
    Detail5008,
    Detail5007,
    AmountRangeSearch,
    QueryDetailDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfigCheck2,
      defaultEventKey:"defaultEventKey",
      //数据字典
      searchFormDictList: [
        "TXN_STATUS",
        "RegionId",
        "BIZ_TYPE_111",
        "PRIORITY3CODE",
        "CUST_FLAG1",
        "TXN_STATUS",
        "PKG_STATUS",
        "PROCESSSTATUS",
        "CBFLAG",
        "NON_STP_TYPE",
        'TXN_SOURCE',
        "BUDGETLEVELCODE",
        "BUDGETTYPECODE",
        "INDICATOR_CODE"
      ],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: "",
        cpgdate: "",
        cpgdate2: "",
        workdate: "",
        workdat2: "",
        source: "",
      },
      formOptions: [],
      tableBindColumns: [
        { label: `系统编号`, prop: "sysCode", dictCode: "SYS_CODE", width: "120" },
        { label: `交易流水号`, prop: "coreId", width: "160" },
        { label: `CPG日期`, prop: "vdate", width: "100", sortable: false },
        { label: `工作日期`, prop: "workdate", width: "100" },
        {
          label: `报文类型`,
          prop: "msgType",
          dictCode: 'PKG_TYPE_HVPSBEPS',
          sortable: false, formatter: (row) => {
            if(!row.bizTypeCode) {
              return '-'
            }
            return `${row.bizTypeCode + '-' + row.bizTypeCodeDesc}`;
          }
        },
        { label: `业务类型`, prop: "bizTypeCode", formatter: (row) => {
            if(!row.bizTypeCode) {
              return '-'
            }
            return `${row.bizTypeCode + '-' + row.bizTypeCodeDesc}`;
          }, sortable: false, width: 200 },
        { label: `业务种类`, prop: "bizCtgyCode", formatter: (row) => {
            if(!row.bizCtgyCode) {
              return '-'
            }
            return `${row.bizCtgyCode + '-' + row.bizCtgyCodeDesc}`;
          }, sortable: false, width: 200
        },
        {
          label: `业务状态`,
          prop: "status",
          width: "100",
          dictCode: "TXN_STATUS",
          sortable: false,
        },
        {
          label: `来源`,
          prop: "source",
          width: "100",
          dictCode: "TXN_SOURCE",
          sortable: false,
        },
        {
          label: `录入操作员`,
          prop: "mdTlrno",
          width: "100",
          sortable: false,
        },
        {
          label: `录入时间`,
          prop: "mdTime",
          width: "160",
          sortable: false,
        },
      ],
    };
  },
  computed: {
    ...mapGetters(["name", "globalBusData"]),
  },
  created() {
    this.queryParams.mdTlrno = this.name;
    this.queryParams.brno = this.globalBusData.brno;
  },
  mounted() {
    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "TXN_SOURCE",
        prop: "source",
        defaultAttr: {
          label: "来源",
          placeholder: "请选择来源",
        },
      },
    ];
  },
  methods: {
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.$refs.dataTable.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    transAdd() {
      console.log("this.$refs.editInfoDialog", this.$refs.editInfoDialog);
      this.$refs.editInfoDialog.show();
    },
    /*查看明细*/
    toViewDetail(row) {
      if(row.msgType==='beps.133.001.01'){
        this.$refs.detail5008.show(row.coreId,row.msgType);
      }else if(row.msgType==='beps.127.001.01'||row.msgType==='beps.127.001.02'){
        this.$refs.detail5007.show(row.coreId,row.msgType);
      }
    },

  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
